/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dale2507.gates.gate.comparator;

import dale2507.gates.gate.Address;
import dale2507.gates.gate.Gate;

/**
 *
 * @author Dale
 */
public class GateAddressComparator implements IGateComparator {

    /**
     * Checks if a gate matches the address. 
     * @param g Gate to check for the address
     * @param item Address to check for
     * @return true if the address is part for the gate, false otherwise
     */
    @Override
    public boolean check(Gate g, Object item) {
        if (item == null) return false;
        if (!(item instanceof Address)) return false;
        if (g.getSettings().getAddress() == null || !g.getSettings().getAddress().equals(item)) return false;
        return true;
    }
    
}
